/*
 * 图集模块接口
 * @Description: jishupu-admin-template
 * @Author: 技术铺<jishupu@qq.com>
 * @Date: 2021-11-15
 */

import request from '@/utils/request'

/**
  * 列表
  * @param {Number} cid 栏目标识
  * @param {Object} params
  * @param {Object} extendConfig
  * @returns  new Promise
 */
export function index(cid, params, extendConfig) {
  return request.get(`/v1/info-category/${cid}/info-picture`, { params, ...extendConfig })
}

/**
  * 添加
  * @param {Number} cid 栏目标识
  * @param {Object} params
  * @param {Object} extendConfig
  * @returns
 */
export function store(cid, params, extendConfig) {
  return request.post(`/v1/info-category/${cid}/info-picture`, params, extendConfig)
}

/**
  * 查看
  * @param {Number} cid 栏目标识
  * @param {Number} id 标识
  * @param {Object} extendConfig
  * @returns  new Promise
 */
export function show(cid, id, extendConfig) {
  return request.get(`/v1/info-category/${cid}/info-picture/${id}`, extendConfig)
}

/**
 * 修改
 * @param {Number} cid 栏目标识
 * @param {Number} id 标识
 * @param {Object} params
 * @param {Object} extendConfig
 * @returns  new Promise
 */
export function update(cid, id, params, extendConfig) {
  return request.put(`/v1/info-category/${cid}/info-picture/${id}`, params, extendConfig)
}

/**
 * 删除
 * @param {Number} cid 栏目标识
 * @param {Number | String} id  例：数字1或字符串1,2,3
 * @param {Object} extendConfig
 * @returns  new Promise
 */
export function destory(cid, id, extendConfig) {
  return request.delete(`/v1/info-category/${cid}/info-picture/${id}`, extendConfig)
}

/**
 * 更新状态
 * @param {Number} cid 栏目标识
 * @param {Number} id 标识
 * @param {Object} params 参数如：{ status: 0 }
 * @param {Object} extendConfig
 * @returns  new Promise
 */
export function updateStatus(cid, id, params, extendConfig) {
  return request.patch(`/v1/info-category/${cid}/info-picture/${id}/status`, params, extendConfig)
}

/**
 * 更新排序
 * @param {Number} cid 数据字典标识
 * @param {Object} params 参数如：{sort: [{id: 7, sort: 2}, {id: 8, sort: 1}]}
 * @param {Object} extendConfig
 * @returns  new Promise
 */
export function updateSort(cid, params, extendConfig) {
  return request.put(`/v1/info-category/${cid}/info-picture/sort`, params, extendConfig)
}

/**
 * 置顶
 * @param {Number} cid 栏目标识
 * @param {Number} id 标识
 * @param {Object} params 参数如：{ top: 1 }
 * @param {Object} extendConfig 扩展配置
 * @returns  new Promise
 */
export function updateTop(cid, id, params, extendConfig) {
  return request.patch(`/v1/info-category/${cid}/info-picture/${id}/top`, params, extendConfig)
}
